__all__ = (
    'SpecialFloat',
    'SpecialFloatEncoder',
)

import json
from typing import Any


class SpecialFloat:
    __slots__ = (
        'value',
    )

    def __init__(self, value: float):
        self.value = value


class SpecialFloatEncoder(json.JSONEncoder):

    def default(self, o: Any) -> Any:
        if isinstance(o, SpecialFloat):
            return format(o.value, '.4e')

        return super().default(o)
